package com.frejoys.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.frejoys.common.dto.app.AddUserAddressDto;
import com.frejoys.common.dto.app.UpdateAddressDto;
import com.frejoys.common.vo.app.UserAddressVo;
import com.frejoys.dao.entity.User;
import com.frejoys.dao.entity.UserAddress;

import java.util.List;

public interface UserAddressService extends IService<UserAddress> {
    default UserAddress getOnly(QueryWrapper<UserAddress> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    default UserAddress getOnly(LambdaQueryWrapper<UserAddress> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }


    /**设置默认收获地址
     *
     * @param userId 用户id
     * @param id 收货地址id
     * @return
     */
    Integer setOnAddress(Long userId, Integer id);


    /**删除收获地址
     *
     * @param id 收货地址id
     * @return
     */
    Integer deleteAddress(Integer id);


    /**添加收获地址
     *
     * @param userId
     * @param addUserAddressDto
     */
    Integer addUserAddress(Long userId, AddUserAddressDto addUserAddressDto);


    /**查询收获地址列表
     *
     * @param userId
     * @return
     */
    List<UserAddressVo> userAddressList(Long userId);


    /** 修改收获地址信息
     *
     * @param dto
     * @return
     */
    Integer updateAddress(UpdateAddressDto dto);
}
